<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Language" CONTENT="zh-tw">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>節目表</TITLE>
<script language="javascript">
var pW = window.dialogArguments;
var tvProg = pW.tvProg;
var tomorrowProg = pW.tomorrowProg;
function timeString(sec) {
	if(sec<0) sec+= 3600*24;
	var hh = '0'+Math.floor(sec/3600);
	var mm = '0'+Math.floor((sec-(hh*3600))/60);
   hh = hh.substr(hh.length-2);
	mm = mm.substr(mm.length-2);
	return(hh+':'+mm);
}

function prog2HTML(s) {
   s = s.replace(/^(.*)(【.+】)(.+)\t(.*)$/,'$1$3\t$2$4');
   s = s.replace(/\t(.+)$/,' <wbr><span style="color:gray">$1</span>');
   return(s);
}

function init() {
	location.href='#ActivePg';
}

function viewTomm(o){
	
	if(o.innerText == '顯示明日節目表') {
		o.innerText = '明日節目表';
		document.all.tomTab.style.display = 'inline';
	}
	else {
		o.innerText = '顯示明日節目表';
		document.all.tomTab.style.display = 'none';
	}

}


</script>
<style>
	.c1 {background-color:'#33CCFF';}
	.c2 {background-color:'#AAEEFF';}
	.c3 {background-color:'#FF5151';}
	a { color:#000000; text-decoration:none; }
	a:hover{ color:#0000ff; text-decoration:none; }
	
</style>
</HEAD>
<BODY bgcolor="#eeeeff" LEFTMARGIN=8 RIGHTMARGIN=8 TOPMARGIN=8 onload="init()">
<center>
<script language="javascript">
	var d = new Date();
   var dy = d.getFullYear();
   var dm = d.getMonth()+1;
   var dd = d.getDate();
   
   var tvFullName = pW.rightMouseTvName;

	document.title=dy+'年'+dm+'月'+dd+'日 - '+pW.rightMouseTvName;
	var tvName = pW.chYahoo[pW.rightMouseTvName];
	var nowSec = d.getHours()*3600 + d.getMinutes() * 60 + d.getSeconds();
	var tStart,tEnd;
	var cName = 'c1';
	
	if(tvProg[tvName]) {
		
		document.write('<table width=100% style="font-size:9pt" cellspacing=0 cellpadding=2>');
      for(i=0;i<tvProg[tvName].length;i++) {
			tStart = tvProg[tvName][i][0];
			tEnd = (i+1==tvProg[tvName].length)?86400:tvProg[tvName][i+1][0];
         cName = (i%2)?'c1':'c2';
         if(nowSec>=tStart && nowSec<tEnd) cName = 'c3'; //現在?
			document.write('<tr class='+cName+'><td width=40 align=center>'+timeString(tvProg[tvName][i][0])+'</td><td>'+(cName=='c3'?'<A NAME="ActivePg">':'')+'<a href="http://www.google.com.tw/search?q='+encodeURI(tvFullName+' '+tvProg[tvName][i][1])+'">'+prog2HTML(tvProg[tvName][i][1])+'</a></td></tr>');
      }
		document.write('</table>');

		document.write('<table width=100% cellspacing=0 cellpadding=2><tr><th bgcolor=#000080><span style="cursor:hand;font-size:9pt; color: #ffffff" onclick="viewTomm(this)">顯示明日節目表</span></th></tr></table>');


		document.write('<table id=tomTab style="display: none; font-size:9pt" width=100% cellspacing=0 cellpadding=2>');
      if(tomorrowProg != null && tomorrowProg[tvName]) {
	      for(i=0;i<tomorrowProg[tvName].length;i++) {
				tStart = tomorrowProg[tvName][i][0];
				tEnd = (i+1==tomorrowProg[tvName].length)?86400:tomorrowProg[tvName][i+1][0];
	         cName = (i%2)?'c1':'c2';
				document.write('<tr class='+cName+'><td width=40 align=center>'+timeString(tomorrowProg[tvName][i][0])+'</td><td><a href="http://www.google.com.tw/search?q='+encodeURI(tvFullName+' '+tomorrowProg[tvName][i][1])+'">'+prog2HTML(tomorrowProg[tvName][i][1])+'</a></td></tr>');
	      }
		}
		else {
			document.write('<tr><td>尚無資料</td></tr>');
		}
		document.write('</table>');



	}
	else {
		document.write('<table width=100% height=100%><tr><td align=center valign=middle>該頻道無節目資訊</td></tr></table>');
	}

</script>	



</center>
</BODY>	
</HTML>